<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .red {
            color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <h1>{{msg}}</h1>
        <com1 title="我是node标题" :list="list"></com1>
        <com2 :title=msg></com2>
    </div>

    <script src="./js/vue.js"></script>
    <script>
        let com1 = {
            props: {
                title: String,
                list: Array
            },
            data() {
                return {}
            },
            template: `<div>我是com1+{{title}}
                <ul>
                    <li v-for="(item,index) of list" :key="item.id" :class="{red:index==0}">{{item.name}}</li>
                </ul>
            </div>`
        }
        let com2 = {
            props: {
                title: String
            },
            data() {
                return {}
            },
            template: "<div>我是com2+{{title}}</div>"
        }
        let vm = new Vue({
            el: '#app',
            data: {
                msg: "Hello Vue",
                list: [{
                        id: 1,
                        name: "vue不难"
                    },
                    {
                        id: 2,
                        name: "vue不难,需要用心"
                    },
                    {
                        id: 3,
                        name: "vue真的不难,需要用心"
                    }
                ]
            },
            methods: {},
            components: {
                com1,
                com2
            },
            mounted() {
                setTimeout(() => this.msg = "我是你爸爸", 3000)
            }
        });
    </script>
</body>

</html>